package com.qfedu.knowledge.controller;

import com.qfedu.knowledge.entity.dto.DictDTO;
import com.qfedu.knowledge.entity.vo.ResultVO;
import com.qfedu.knowledge.service.IDictValueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName DictValueController
 * @Author ykx
 * @Date 2024/1/9 16:00
 * @Version 1.0
 */
@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/knowledge/dict")
public class DictValueController {

    @Autowired
    private IDictValueService dictValueService;

    /**
     * 根据itemCode获取下拉列表
     *
     * @param itemCode itemCode
     * @return ResultVO
     */
    @GetMapping("/getListByItemCode")
    public ResultVO getDictListByItemCode(String itemCode) {
        return ResultVO.success(dictValueService.getDictListByItemCode(itemCode));
    }

    @PostMapping("/add")
    public ResultVO add(@RequestBody DictDTO dictDTO) {
        return ResultVO.success(dictValueService.addDict(dictDTO));
    }

    @DeleteMapping("/{id}")
    public ResultVO del(@PathVariable Long id) {
        return ResultVO.success(dictValueService.removeById(id));
    }

}
